package com.example.logutil.impl;

import android.util.Log;

import com.example.logutil.ILogger;
import com.example.logutil.common.LogLevel;

public class Logcatlmpl implements ILogger {
    private  String tamplete = "[%s]--->[%s] [%s]";
    private boolean mIsDebug = false;
    private String mTag = "bawei";
    private LogLevel mLevel = LogLevel.INFO;


    @Override
    public void isDebug(boolean isDebug) {
        this.mIsDebug = isDebug;
    }

    @Override
    public void setTag(String setTag) {
        this.mTag = setTag;
    }

    @Override
    public void setLevel(LogLevel level) {
        this.mLevel = level;
    }



    @Override
    public void i(String subTag, String log) {
        if (mIsDebug&&LogLevel.INFO.ordinal()>=mLevel.ordinal()){
            Log.i(this.mTag,String.format(tamplete,subTag,this.mTag,log));
        }
    }

    @Override
    public void d(String subTag, String log) {
        if (mIsDebug&&LogLevel.DEBUG.ordinal()>=mLevel.ordinal()){
            Log.d(this.mTag,String.format(tamplete,subTag,this.mTag,log));
        }
    }

    @Override
    public void w(String subTag, String log) {
        if (mIsDebug&&LogLevel.WARN.ordinal()>=mLevel.ordinal()){
            Log.w(this.mTag,String.format(tamplete,subTag,this.mTag,log));
        }
    }

    @Override
    public void e(String subTag, String log) {
        if (mIsDebug&&LogLevel.ERROR.ordinal()>=mLevel.ordinal()){
            Log.e(this.mTag,String.format(tamplete,subTag,this.mTag,log));
        }
    }
}
